//
// Created by aaa on 2025/7/12.
//

#include<bits/stdc++.h>

using namespace std;
const int N = 1e3 + 10;

int n,m,mm,w,ww,v;
int dp[N][N];

//二维费用背包
//4 5 6
//1 2 3
//2 4 4
//3 4 5
//4 5 6
int main(){
    cin >> n >> m >> mm;

    for(int i = 1;i <= n;i++){
        cin >> w >> ww >> v;

        for(int j = m;j >= w;j--){
            for(int k = mm;k >= ww;k--){
                dp[j][k] = max(dp[j][k],dp[j-w][k-ww] + v);
            }
        }
    }

    cout << dp[m][mm];

    return 0;
}